import { AutoGuideStepBase } from "./AutoGuideStepBase";
import { IAutoGuideSteper } from "./IAutoGuideSteper";
import { AutoGuideData } from "../AutoGuideData";
import { Window } from "../../../../../component/window/Window";
import { GameController } from "../../../../mvc/GameController";
import { DisplayUtil } from "../../../../../common/DisplayUtil";
import { AutoGuideClickType } from "../AutoGuideClickType";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
//class AutoGuideRightDownIconSteper
    
    export  class AutoGuideRightDownIconSteper extends AutoGuideStepBase implements IAutoGuideSteper
    {
        constructor()
        {
            super();
            return;
        }

        public guide(arg1: AutoGuideData, arg2: Window=null): void
        {
            if (arg1 == null || arg1.guideTypeValue == null || arg1.guideTypeValue == "") 
            {
                return;
            }
            _data = arg1;
            var loc1=GameController.gameui.getGameui().navbar;
            var loc2=GameController.gameui.getGameui().navbarSprite;
            var loc3;
            if ((loc3 = DisplayUtil.getChildByPropety(loc1, "name", String(arg1.guideTypeValue))) == null) 
            {
                loc3 = DisplayUtil.getChildByPropety(loc2, "name", String(arg1.guideTypeValue));
            }
            if (loc3 == null) 
            {
                return;
            }
            this._opBtn = loc3;
            arrow.x = loc3.x + 21;
            arrow.y = loc3.y - 8;
            arrow.updateDir(arg1.arrowDirection);
            loc3.parent.addChild(arrow);
            if (_updatePlaceTiemr != null) 
            {
                _updatePlaceTiemr.stop();
            }
            else 
            {
                _updatePlaceTiemr = new Object /* flash.utils.Timer */(200);
                _updatePlaceTiemr.addEventListener(flash.events.TimerEvent.TIMER, this.everyTime);
            }
            _updatePlaceTiemr.start();
            _datas[loc3] = arg1;
            if (arg1.clickType != AutoGuideClickType.Click) 
            {
                loc3.addEventListener(flash.events.MouseEvent.DOUBLE_CLICK, this.clickOpBtnHandler, false, 10000000);
            }
            else 
            {
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.clickOpBtnHandler, false, 10000000);
            }
            return;
        }

        /* internal  */everyTime(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._opBtn == null) 
            {
                return;
            }
            arrow.x = this._opBtn.x + 21;
            arrow.y = this._opBtn.y - 8;
            return;
        }

        /* internal  */clickOpBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            DisplayUtil.removeMe(_arrow);
            var loc1=arg1.currentTarget as Object /* flash.display.DisplayObject */;
            loc1.removeEventListener(flash.events.MouseEvent.CLICK, this.clickOpBtnHandler);
            loc1.removeEventListener(flash.events.MouseEvent.DOUBLE_CLICK, this.clickOpBtnHandler);
            var loc2=_datas[loc1];
            if (loc2 != null) 
            {
                _datas[loc1] = null;
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, loc2));
            }
            return;
        }

        public stop(arg1: AutoGuideData=null): void
        {
            return;
        }

        /* internal */ /* var */_opBtn: Object /* flash.display.DisplayObject */;
    }
